import Vue from 'vue'
import VueRouter from 'vue-router'
import Login from '../views/Login.vue'


// 把这段代码直接粘贴到router/index.js中的Vue.use(VueRouter)之前
const originalPush = VueRouter.prototype.push;
VueRouter.prototype.push = function (location) {
  return originalPush.call(this, location).catch(err => { })
};
Vue.use(VueRouter)

const routes = [
  // 重定向到登录
  {
    path: '/',
    redirect: '/login'
  },

  //登录路由 
  {
    path: '/login',
    name: 'Login',
    component: Login
  },

  // 首页路由
  {
    path: '/home',
    name: 'Home',
    component: () => import(/* webpackChunkName: "home" */ '../views/Home.vue'),
    meta: {
      activeNum: 0,
      isShowTabbar: true
    }
  },

  // 用户路由
  {
    path: '/user',
    name: 'User',
    component: () => import(/* webpackChunkName: "user" */ '../views/User.vue'),
    meta: {
      activeNum: 2,
      isShowTabbar: true
    }
  },

  // 用户信息路由
  {
    path: '/userinfo',
    name: 'Userinfo',
    component: () => import(/* webpackChunkName: "userinfo" */ '../views/Userinfo.vue')
  },

  // 用户版本信息路由
  {
    path: '/userVersions',
    name: 'UserVersions',
    component: () => import(/* webpackChunkName: "userVersions" */ '../views/UserVersions.vue')
  },

  // 发货单路由
  {
    path: '/shipments',
    name: 'Shipments',
    component: () => import(/* webpackChunkName: "shipments" */ '../views/Shipments.vue'),
    // children: [
    //   {
    //     path: '/shipments/deliveryConfirmation',
    //     name: 'DeliveryConfirmation',
    //     component: () => import(/* webpackChunkName: "deliveryConfirmation" */ '../components/DeliveryConfirmation.vue')
    //   }
    // ]
  },

  // 发货单-发货页面路由
  {
    path: '/deliveryConfirmation',
    name: 'DeliveryConfirmation',
    component: () => import(/* webpackChunkName: "deliveryConfirmation" */ '../views/DeliveryConfirmation.vue')
  },

  // 发货单-评价路由
  {
    path: '/comment',
    name: 'Comment',
    component: () => import(/* webpackChunkName: "comment" */ '../views/Comment.vue')
  },

  // 发货单-查看评价路由
  {
    path: '/seeTheEvaluation',
    name: 'SeeTheEvaluation',
    component: () => import(/* webpackChunkName: "seeTheEvaluation" */ '../views/SeeTheEvaluation.vue')
  },

  // 信息中心路由
  {
    path: '/informationCenter',
    name: 'InformationCenter',
    component: () => import(/* webpackChunkName: "informationCenter" */ '../views/InformationCenter.vue')
  },

  // 信息中心-消息详情
  {
    path: '/informationDetails',
    name: 'InformationDetails',
    component: () => import(/* webpackChunkName: "informationDetails" */ '../views/InformationDetails.vue')
  },

  // 物流单
  {
    path: '/logisticsBill',
    name: 'LogisticsBill',
    component: () => import(/* webpackChunkName: "logisticsBill" */ '../views/LogisticsBill.vue')
  },

  // 物流单评价
  {
    path: '/logisticListEvaluation',
    name: 'LogisticListEvaluation',
    component: () => import(/* webpackChunkName: "logisticListEvaluation" */ '../views/LogisticListEvaluation.vue')
  },

  // 查看物流单评价
  {
    path: '/logisticListEvaluationExamine',
    name: 'LogisticListEvaluationExamine',
    component: () => import(/* webpackChunkName: "logisticListEvaluationExamine" */ '../views/LogisticListEvaluationExamine.vue')
  },

  // 客户管理
  {
    path: '/customerManagement',
    name: 'CustomerManagement',
    component: () => import(/* webpackChunkName: "customerManagement" */ '../views/CustomerManagement.vue')
  },

  // 客户
  {
    path: '/client',
    name: 'Client',
    component: () => import(/* webpackChunkName: "client" */ '../views/Client.vue')
  },

  // 客户信息详情
  {
    path: '/customerInformationDetails',
    name: 'CustomerInformationDetails',
    component: () => import(/* webpackChunkName: "customerInformationDetails" */ '../views/CustomerInformationDetails.vue')
  },
  // 编辑客户信息
  {
    path: '/editCustomerInformation',
    name: 'EditCustomerInformation',
    component: () => import(/* webpackChunkName: "editCustomerInformation" */ '../views/EditCustomerInformation1.vue')
  },

  // 新增客户
  {
    path: '/newCustomer',
    name: 'NewCustomer',
    component: () => import(/* webpackChunkName: "newCustomer" */ '../views/NewCustomer.vue')
  },

  // 客户关怀
  {
    path: '/customerCare',
    name: 'CustomerCare',
    component: () => import(/* webpackChunkName: "customerCare" */ '../views/CustomerCare.vue')
  },

  // 新增拜访

  {
    path: '/newlyIncreasedCallOn',
    name: 'NewlyIncreasedCallOn',
    component: () => import(/* webpackChunkName: "newlyIncreasedCallOn" */ '../views/NewlyIncreasedCallOn.vue')
  },

  // 客户关怀-选择客户
  {
    path: '/selectTheCustomer',
    name: 'SelectTheCustomer',
    component: () => import(/* webpackChunkName: "selectTheCustomer" */ '../views/SelectTheCustomer.vue')
  },
  // 客户关怀-拜访详情
  {
    path: '/visitDetails',
    name: 'VisitDetails',
    component: () => import(/* webpackChunkName: "visitDetails" */ '../views/VisitDetails.vue')
  },


  // {
  //   path: '/about',
  //   name: 'About',
  //   // route level code-splitting
  //   // this generates a separate chunk (about.[hash].js) for this route
  //   // which is lazy-loaded when the route is visited.
  //   component: () => import(/* webpackChunkName: "about" */ '../views/About.vue')
  // }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
